package com.cyq.day13.game;

import java.util.Scanner;

public class Game {
    Scanner scanner=new Scanner(System.in);
    public void Fistgame(){
        Computer computer=new Computer();
        Human human=new Human();
        computer.score=0;
        human.score=0;
        for (int i=0;i<3;i++){
            //剪刀为0,石头为1,布为2
            computer.num=(int)(Math.random()*3);
            //System.out.println("电脑随机生成的是："+computer.num);
            //人的猜拳结果
            System.out.println("请输入第"+(i+1)+"次要出什么(剪刀为0,石头为1,布为2)");
            human.num=scanner.nextInt();
            if (human.num>2||human.num<0){
                System.out.println("输入有误");
                return;
            }
            if (computer.num==0){
                if (human.num==1){
                    human.score++;
                }else if(human.num==2){
                    computer.score++;
                }
            }
            if (computer.num==1){
                if (human.num==0){
                    computer.score++;
                }else if(human.num==2){
                    human.score++;
                }
            }
            if (computer.num==2){
                if (human.num==0){
                    human.score++;
                }else if(human.num==1){
                    computer.score++;
                }
            }
        }
        if (computer.score>human.score){
            System.out.println("电脑胜利");
        }
        if (human.score>computer.score){
            System.out.println("你胜利了");
        }
        if (human.score==computer.score){
            System.out.println("平局");
        }
    }
}
